<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TTS语音合成服务</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        
        .container {
            background: white;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        
        .section {
            margin-bottom: 30px;
            padding: 20px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            background-color: #fafafa;
        }
        
        .section h2 {
            color: #555;
            margin-top: 0;
            border-bottom: 2px solid #007bff;
            padding-bottom: 10px;
        }
        
        .input-group {
            margin-bottom: 15px;
        }
        
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #333;
        }
        
        input[type="text"], textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
            box-sizing: border-box;
        }
        
        textarea {
            height: 100px;
            resize: vertical;
        }
        
        button {
            background-color: #007bff;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            margin-right: 10px;
            margin-bottom: 10px;
            transition: background-color 0.3s;
        }
        
        button:hover {
            background-color: #0056b3;
        }
        
        button:disabled {
            background-color: #6c757d;
            cursor: not-allowed;
        }
        
        .danger {
            background-color: #dc3545;
        }
        
        .danger:hover {
            background-color: #c82333;
        }
        
        .success {
            background-color: #28a745;
        }
        
        .success:hover {
            background-color: #218838;
        }
        
        .audio-player {
            margin-top: 15px;
            padding: 15px;
            background-color: #e9ecef;
            border-radius: 5px;
            text-align: center;
        }
        
        audio {
            width: 100%;
            max-width: 500px;
        }
        
        .status {
            margin-top: 10px;
            padding: 10px;
            border-radius: 5px;
            font-weight: bold;
        }
        
        .status.loading {
            background-color: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }
        
        .status.success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        
        .status.error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        
        .segment {
            padding: 15px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: white;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .segment:hover {
            background-color: #f8f9fa;
            border-color: #007bff;
            transform: translateY(-2px);
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        
        .segment.active {
            background-color: #e3f2fd;
            border-color: #2196f3;
        }
        
        .active-requests {
            max-height: 200px;
            overflow-y: auto;
            background-color: white;
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 10px;
        }
        
        .request-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px;
            border-bottom: 1px solid #eee;
        }
        
        .request-item:last-child {
            border-bottom: none;
        }
        
        .request-info {
            flex: 1;
        }
        
        .request-id {
            font-weight: bold;
            color: #007bff;
        }
        
        .request-duration {
            color: #666;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎵 TTS语音合成服务</h1>
        
        <!-- 基础TTS功能 -->
        <div class="section">
            <h2>📝 文本转语音</h2>
            <div class="input-group">
                <label for="ttsText">输入要转换的文本：</label>
                <textarea id="ttsText" placeholder="请输入要转换为语音的文本内容...">你好，欢迎使用TTS语音合成服务！</textarea>
            </div>
            <button id="startTTS" onclick="startTTS()">开始转换</button>
            <button id="cancelTTS" onclick="cancelTTS()" disabled class="danger">取消转换</button>
            <div id="ttsStatus" class="status" style="display: none;"></div>
            <div id="audioContainer" class="audio-player" style="display: none;">
                <audio id="audioPlayer" controls></audio>
            </div>
        </div>
        
        <!-- 浏览器原生TTS功能 -->
        <!-- <div class="section">
            <h2>🌐 浏览器原生语音合成</h2>
            <div class="input-group">
                <label for="nativeText">输入文本：</label>
                <input type="text" id="nativeText" placeholder="输入要朗读的文本" value="你好，今天能够为你做什么">
            </div>
            <button onclick="startNativeTTS()">开始朗读</button>
            <button onclick="stopNativeTTS()">停止朗读</button>
        </div> -->
        
        <!-- 分段TTS功能 -->
        <!-- <div class="section">
            <h2>📚 分段语音合成</h2>
            <p>点击下面的段落进行语音合成，鼠标悬停时会自动取消之前的请求：</p>
            <div class="segment" data-segment="第一段：欢迎使用TTS语音合成服务">
                第一段：欢迎使用TTS语音合成服务
            </div>
            <div class="segment" data-segment="第二段：这是一个功能强大的文本转语音系统">
                第二段：这是一个功能强大的文本转语音系统
            </div>
            <div class="segment" data-segment="第三段：支持多种语音合成方式">
                第三段：支持多种语音合成方式
            </div>
        </div> -->
        
        <!-- 活跃请求监控 -->
        <!-- <div class="section">
            <h2>📊 活跃请求监控</h2>
            <button onclick="refreshActiveRequests()">刷新</button>
            <div id="activeRequests" class="active-requests">
                <p>暂无活跃请求</p>
            </div>
        </div> -->
    </div>

    <script src="./index.js"></script>
</body>
</html>
